'''
coding:utf-8
:writingtime: 2022-6-27
:author: wanjun
:reference: Information measures for q‐rung orthopair fuzzy sets
:doi: 10.1002/int.22115
:examiner: 
'''

def getSimilarity(a_list,b_list,q=3):
    if len(a_list)!=len(b_list):
        print('两个集合论域错误')
    length = len(a_list)
    sum1=0;sum2=0
    for i in range(length):
        value1=(min(a_list[i][0][0]**q,b_list[i][0][0]**q)+min(a_list[i][0][1]**q,b_list[i][0][1]**q)+
                min((1-a_list[i][1][0]**q),(1-b_list[i][1][0]**q))+min((1-a_list[i][1][1]**q),(1-b_list[i][1][1]**q)))
        value2=(max(a_list[i][0][0]**q,b_list[i][0][0]**q)+max(a_list[i][0][1]**q,b_list[i][0][1]**q)+
                max((1-a_list[i][1][0]**q),(1-b_list[i][1][0]**q))+max((1-a_list[i][1][1]**q),(1-b_list[i][1][1]**q)))
        sum1+=value1
        sum2+=value2
    #final_value=sum1/sum2

    final_value = sum1 / sum2
    return final_value


if __name__=='__main__':
    print(getSimilarity([[[0.3509, 0.3509], [0.3509, 0.3509]]], [[[0.4009, 0.4009], [0.4009, 0.4009]]],3))


